package com.cp.weixin.crawler.service.impl;

import com.cp.weixin.es.dao.NotPassLinkMapper;
import com.cp.weixin.crawler.service.NotPassLinkService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

@Service
public class NotPassLinkServiceImpl implements NotPassLinkService {

	@Autowired
	NotPassLinkMapper notPassLinkMapper;

	@Override
	public int addLink(String link) {
		if(StringUtils.isNotEmpty(link)) {
			String md5 = DigestUtils.md5DigestAsHex(link.getBytes());
			return notPassLinkMapper.addLink(link, md5);
		}else {
			return 0;
		}
	}
}
